class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) {
        int n=price.size();
        int left=0;
        int right=n-1;
        vector<int> v;
        while(left<right)
        {
            if(price[left]+price[right]>target)
            {
                right--;
            }
            else if(price[left]+price[right]<target)
            {
                left++;
            }
            else
            {
                v.push_back(price[left]);
                v.push_back(price[right]);
                break;
            }
        }
        return v;
    }
};
